class Rectangle(object):
  def __init__(self, left, top, right, bottom):
    self._l = left
    self._t = top
    self._r = right
    self._b = bottom

    if (self.w <= 0):
      raise Exception ("negative width")

    if (self.h <= 0):
      raise Exception ("negative height")

  @property
  def l(self):
    return self._l

  @property
  def t(self):
    return self._t
  
  @property
  def r(self):
    return self._r
  
  @property
  def b(self):
    return self._b

  @property
  def w(self):
    return self.r - self.l

  @property
  def h(self):
    return self.b - self.t

  def intersects(self, other):
    return not (
      self.l >= other.r or 
      self.t >= other.b or
      self.r <= other.l or
      self.b <= other.t
      )

  @property
  def ltrb(self):
    return (self.l, self.t, self.r, self.b)

  def __repr__(self):
    return "[l:%d t:%d r:%d b:%d (w:%d h:%d)]" % (self.l, self.t, self.r, self.b, self.w, self.h)
